package com.it.dao;

import com.it.base.BaseDAO;
import com.it.bean.TopicBean;

import java.util.List;

public class TopicDaoImpl extends BaseDAO<TopicBean> implements TopicDao {
    @Override
    public void addTopic(TopicBean topicBean) throws Exception {
        String sql = "insert into t_topic value (?,?,?,?,?)";
        super.executeUpdate(sql, 0, topicBean.getContent(), topicBean.getTopicDate(), topicBean.getTitle(), topicBean.getUid());

    }

    @Override
    public List<TopicBean> getTopicListByUid(Integer uid) throws Exception {
        String sql = "select * from t_topic where uid = ?";
        return super.executeQuery(sql, uid);
    }

    @Override
    public void deleteTopic(TopicBean topicBean) throws Exception {
        String sql = "delete from t_topic where id = ?";
        super.executeUpdate(sql, topicBean.getId());

    }

    @Override
    public TopicBean getTopicById(Integer topicId) throws Exception {
        String sql = "select * from t_topic where id = ?";
        return super.load(sql, topicId);
    }
}
